/* 获取订单号 */
var request = GetRequest();
var prescription_id = request['prescription_id'];
var indent_no = request['indent_no'];
var uid = sessionStorage.getItem("u_group_no");
//显示数据
function showChatPage(pageIndex, pageId) {
	var paramJson, strDoName;
	nPageIndex = pageIndex;
	switch (nPageIndex) {
		case "1": //处方
			paramJson = { "prescription_id": prescription_id };
			strDoName = "publicUtil_getInquiryLogPrescriptionDetails";
			break;
		case "2": //检验检查
			paramJson = { "checklist_id": pageId };
			strDoName = "publicUtil_getInquiryLogChecklistDetails";
			break;
		case "3": //健康指导
			paramJson = { "guidance_id": pageId };
			strDoName = "publicUtil_getInquiryLogHealthGuidanceDetails";
			break;
		case "4": //住院建议
			paramJson = { "hospitalization_id": pageId };
			strDoName = "publicUtil_getInquiryLogHospitalizationDetails";
			break;
	}
	ajaxGet(strDoName, paramJson, showChatPageOk);
	return false;
}

function showChatPageOk(jsonInfo) {
	if (jsonInfo.code == '200') {
		var imgUrl, pageTitle;
		var data = jsonInfo.data;
		switch (nPageIndex) {
			case "1": //处方详情
				imgUrl = data.prescriptionMap.prescription_imgurl;
				pageTitle = "处方详情";
				break;
			case "2": //检验检查
				imgUrl = data.checklistMap.imgurl;
				pageTitle = "检验检查";
				break;
			case "3": //健康指导
				imgUrl = getUserImgPub('/' + data.guidanceMap.imgurl);
				pageTitle = "健康指导";
				break;
			case "4": //住院建议
				imgUrl = getUserImgPub('/' + data.hospitalizationMap.imgurl);
				pageTitle = "住院建议";
				break;
		}
		$('.imgShow').attr("src", imgUrl);
	}
	else
		msgInfo(jsonInfo.info);
}

//获取支付状态
function getState(orderid){
	
	paramJson = { "actName": "GetOrderStatus", "order_id": prescription_id, "utype": "5", "uid": uid, "rand": Math.random() };
	ajaxGet("http://zz.nxk520.com/nethosp/service/nethosp_action.ashx", paramJson, getStateOk);
}
//获取成功
function getStateOk(jsonInfo) {
	console.log(jsonInfo)
	var data = jsonInfo.data;
	if(data.pay_status==1){
		// 已支付
		$('#btnBuyOrder').css("pointer-events","none");  
		$('#btnBuyOrder').css("background-color","gray");  
		$('#btnBuyOrder').html("已支付")
	}else{
		//未支付，不操作
	}
}



$(function () {
	strOrgId = getQst("orgid");
	strOpenId = getQst("openid");
	var order_id=getQst("order_id")
	if (isEmpty(order_id))
		order_id = getQst("oid");
	showChatPage("1", order_id);
	getState(order_id);

	//处方流转功能
	$('#btnBuyOrder').on("click", function () {
		window.open('/netcflz_wx/user_dtl1.htm?orgid=' + strOrgId + '&openid=' + strOpenId + '&prescription_id=' + order_id);
	});    
	
	//返回上页
	$('#btnBack').on("click", function () {
		history.go(-1);
	});
});
